#include "bflb_mtimer.h"
#include "board.h"
#include "bflb_gpio.h"
#include "Wire.h"

#define DBG_TAG "MAIN"
#include "log.h"
#include "MPU6050.h"

int main(void)
{
    board_init();

    struct bflb_device_s *gpio = bflb_device_get_by_name("gpio");
    bflb_gpio_init(gpio, GPIO_PIN_12, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
    bflb_gpio_set(gpio, GPIO_PIN_12);

    MPU6050();

    uint8_t deviceId = getDeviceID();

    LOG_E("deviceId: %2x \r\n", deviceId);

    int16_t ax, ay, az;
    int16_t gx, gy, gz;

    while (1) {
       // read raw accel/gyro measurements from device
        getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

        // these methods (and a few others) are also available
        //accelgyro.getAcceleration(&ax, &ay, &az);
        //accelgyro.getRotation(&gx, &gy, &gz);

        // display tab-separated accel/gyro x/y/z values

        LOG_E("a/g:\t ax :%d, ay: %d, az: %d, gx: %d, gy: %d, gz: %d \r\n", ax, ay, az, gx, gy, gz);
    }
}
